<?php
namespace app\appoint\model;
use app\BaseModel;
use think\facade\Db;



class Question extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_question';
    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){

        $query->where('status', '>', $status);
    }

    /**
     * @param $dis
     * @param $page
     * @功能说明:问卷列表
     * @author chenniang
     * @DataTime: 2021-01-25 15:56
     */
    public function dataList($dis,$page){

        $data = $this->where($dis)->status(-1)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;
    }

    /**
     * @param $dis
     * @功能说明:问卷下拉框
     * @author chenniang
     * @DataTime: 2021-01-25 15:56
     */
    public function dataSelect($dis){

        $data = $this->where($dis)->status(-1)->order('top desc')->select()->toArray();

        return $data;
    }

    /**
     * @param $data
     * @功能说明:添加
     * @author chenniang
     * @DataTime: 2021-01-25 15:57
     */
    public function dataAdd($data){

        $data['create_time'] = time();

        $data['update_time'] = time();

        $data['status']      = 1;

        $res = $this->insert($data);

        return $res;
    }

    /**
     * @param $dis
     * @param $data
     * @功能说明:编辑
     * @author chenniang
     * @DataTime: 2021-01-25 15:57
     */
    public function dataUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }

    /**
     * @param $dis
     * @功能说明:详情
     * @author chenniang
     * @DataTime: 2021-01-25 15:57
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->status(-1)->find();

        return !empty($data)?$data->toArray():$data;

    }



}